<?
// Program/Plan/Subject display functions
// Written by John Shepherd, May 2007

function offerRange($first,$last)
{
	$range = "$first .. ";
	if (is_null($last))
		$range .= gray('(continuing)');
	else
		$range .= $last;
	return $range;
}

function section($heading,$text="")
{
	$html = "<h3>$heading</h3>\n";
	if (def($text))
		$html .= "<div style='text-align:justify'>$text</div>";
	return $html;
}

function showKeys($str,$keys)
{
	if (!def($keys)) return $str;
	$keys = preg_split("/[\s,]+/",trim($keys));
	if (count($keys) == 0) return $str;
	$patts = array();
	foreach ($keys as $key) {
		$patt = "/$key/i";
		$check = @preg_match($patt,"abcd");
		if ($check === false) continue;
		$patts[] = $patt;
	}
	if (count($patts) == 0) return $str;
	$replace = '<span class="hilite">$0</span>';
	return preg_replace($patts, $replace, $str);
}

?>
